package rs.fon.rapidminer.serialization;

import java.beans.XMLEncoder;
import java.io.FileOutputStream;

import rs.fon.rapidminer.process.Process;

/**
 * Utill class that encode from proces to xml file.
 * 
 * @author Nikola Nikolic
 */
public class ProcessEncoder {

	/**
	 * 
	 * Method that encode from process to xml file.
	 * 
	 * @param xmlFile
	 *            path to xml file
	 * @param process
	 *            {@link Process}
	 * @return {@link String} simply returns string path to xml file that was
	 *         just encoded to.
	 */
	public static String encodeFormProcesToXML(Process process, String xmlFile) {
		try {
			FileOutputStream out = new FileOutputStream(xmlFile);

			XMLEncoder xml = new XMLEncoder(out);
			xml.writeObject(process);
			xml.close();

			return xmlFile;

		} catch (Exception exc) {
			exc.printStackTrace();
		}

		return null;
	}

}
